package com.iwhalecloud.bss.kite.cucc.service.attr.linkhandler;

import com.iwhalecloud.bss.kite.cucc.common.constant.LocalKeyConsts;
import com.iwhalecloud.bss.kite.cucc.service.attr.handler.DamageFeeSwitchAttrHandler;
import com.iwhalecloud.bss.kite.listener.handler.attr.annotation.AttrHandler;
import com.iwhalecloud.bss.kite.listener.handler.attr.impl.AbstractAttrLinkageHandler;
import com.iwhalecloud.bss.kite.manager.inst.KiteAttr;
import com.iwhalecloud.bss.kite.manager.inst.KiteInst;
import com.iwhalecloud.bss.kite.service.attr.AttrData;
import org.springframework.stereotype.Service;

import java.util.Objects;

@Service
@AttrHandler(DamageFeeSwitchAttrHandler.class)
public class DamageFeeSwitchAttrLinkHandler extends AbstractAttrLinkageHandler<AttrData> {
    @Override
    public void handle(KiteAttr attr, KiteInst inst, AttrData data) {

    }

    @Override
    public void handleStyle(KiteAttr attr, KiteInst inst, AttrData data) {
        //违约金收取方式
        KiteAttr DamageFeeRuleAttr = inst.getAttr("210004555");
        //违约金金额
        KiteAttr DamageFeeAttr = inst.getAttr("210004556");
        if (Objects.isNull(DamageFeeRuleAttr)) {
            return;
        }
        if ("1_0000106".equals(attr.getValue())) {
            //是否收取违约金为是,违约金收取方式展示且必填
            DamageFeeRuleAttr.setIsNull(LocalKeyConsts.IFTRUE_F);
            DamageFeeRuleAttr.setShowType(LocalKeyConsts.PROD_ATTR_SHOW_TYPE_D);

            if ("110007675".equals(DamageFeeRuleAttr.getValue())) {
                //是否收取违约金为是,违约金收取方式为人工录入,违约金金额展示且必填
                DamageFeeAttr.setIsNull(LocalKeyConsts.IFTRUE_F);
                DamageFeeAttr.setShowType(LocalKeyConsts.PROD_ATTR_SHOW_TYPE_D);
            }
        }
        else {
            //是否收取违约金为否,违约金收取方式以及违约金金额不展示
            DamageFeeRuleAttr.setIsNull(LocalKeyConsts.IFTRUE_T);
            DamageFeeRuleAttr.setShowType(LocalKeyConsts.PROD_ATTR_SHOW_TYPE_E);

            DamageFeeAttr.setIsNull(LocalKeyConsts.IFTRUE_T);
            DamageFeeAttr.setShowType(LocalKeyConsts.PROD_ATTR_SHOW_TYPE_E);
        }

    }
}
